package org.example.controller;

import org.common.controller.base.BaseController;
import org.common.controller.base.OR;
import org.common.service.EmailService;
import org.common.type.CaptchaCodeType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class EmailController extends BaseController {

    @Resource
    private EmailService emailService;

    /**
     * 获取验证码
     * @param to
     * @return
     */
    @GetMapping("/getCaptchaCode")
    public ResponseEntity<OR<Void>> sendEmail(@RequestParam String to, @RequestParam CaptchaCodeType type) {
        emailService.sendCaptchaCode(to,type);
        return this.success();
    }
}
